package CyclicBarrierTest;

import java.util.concurrent.CyclicBarrier;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @author zxs
 * @create 2021-03-31 17:25
 */
public class MainClass {
    public static void main(String[] args) {
        System.out.println("考试开始了");
        long start = System.currentTimeMillis();

        CyclicBarrier cyclicBarrier = new CyclicBarrier(5,new TeacherThread());
        ExecutorService executorService = Executors.newCachedThreadPool();

        executorService.execute(new StuThread(600, cyclicBarrier));
        executorService.execute(new StuThread(2000, cyclicBarrier));
        executorService.execute(new StuThread(500, cyclicBarrier));
        executorService.execute(new StuThread(3000, cyclicBarrier));
        executorService.execute(new StuThread(700, cyclicBarrier));

        executorService.shutdown();
    }
}
